#include<bits/stdc++.h>
using namespace std;
int n,m,L,V,d[100005],v[100005],a[100005],p[100005],_;
void sub1(){
    int res=0;
    for(int i=1;i<=n;i++){
        if(v[i]>V){
            if(d[i]<=p[m]){
                res++;
            }
        }
    }
    if(!res){
        cout<<res<<' '<<m<<endl;
    }
    else{
        cout<<res<<' '<<m-1<<endl;
    }
    return;
}
void sub2(){
    int res=0;
    for(int i=1;i<=n;i++){
        if(v[i]>V){
            if(d[i]<=p[m]){
                res++;
            }
        }
        else{
            if(d[i]+1.0*(V*V-v[i]*v[i])/(2.0*a[i])<p[m]){
                res++;
            }
        }
    }
    if(!res){
        cout<<res<<' '<<m<<endl;
    }
    else{
        cout<<res<<' '<<m-1<<endl;
    }
    return;
}
signed main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin>>_;
    while(_--){
        cin>>n>>m>>L>>V;
        bool f1=1,f2=1,f3=1;
        for(int i=1;i<=n;i++){
            cin>>d[i]>>v[i]>>a[i];
            if(a[i]<=0) f1=0;
            if(a[i]!=0) f2=0;
            if(a[i]>=0) f3=0;
        }
        for(int i=1;i<=m;i++){
            cin>>p[i];
        }
        if(f2){
            sub1();
            continue;
        }
        if(f1){
            sub2();
            continue;
        }
    }
    return 0;
}